﻿using System;
using System.Text;

namespace Crypt.Common
{
    public static class Base64
    {
        public static string Encode(string inStr)
        {
            return EncodeFromBytes(Encoding.UTF8.GetBytes(inStr));
        }

        public static string EncodeFromBytes(byte[] inBytes)
        {
            return Convert.ToBase64String(inBytes);
        }

        public static byte[] DecodeToBytes(string inStr)
        {
            return Convert.FromBase64String(inStr);
        }

        public static string Decode(string inStr)
        {
            return Encoding.UTF8.GetString(DecodeToBytes(inStr));
        }
    }
}